<template>
	<view class="container">
		<!-- 支付金额 -->
		<view class="amount-section">
			<text class="label">支付金额</text>
			<text class="amount">¥{{amount}}</text>
		</view>
		
		<!-- 支付方式 -->
		<view class="payment-section">
			<text class="section-title">支付方式</text>
			<view class="payment-list">
				<view 
					class="payment-item" 
					v-for="(item, index) in paymentMethods" 
					:key="index"
					:class="{ active: selectedMethod === item.id }"
					@click="selectMethod(item.id)"
				>
					<view class="method-info">
						<text class="method-icon">{{item.icon}}</text>
						<text class="method-name">{{item.name}}</text>
					</view>
					<text class="check-icon" v-if="selectedMethod === item.id">✓</text>
				</view>
			</view>
		</view>
		
		<!-- 支付按钮 -->
		<view class="footer">
			<button class="pay-btn" @click="handlePay">立即支付</button>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue'

// 支付金额
const amount = ref('69.8')

// 支付方式
const paymentMethods = ref([
	{ id: 'wxpay', name: '微信支付', icon: '💳' },
	{ id: 'alipay', name: '支付宝', icon: '💳' },
	{ id: 'balance', name: '余额支付', icon: '💰' }
])

// 选中的支付方式
const selectedMethod = ref('wxpay')

// 选择支付方式
const selectMethod = (id) => {
	selectedMethod.value = id
}

// 处理支付
const handlePay = () => {
	uni.showLoading({
		title: '支付中...'
	})
	
	// 模拟支付过程
	setTimeout(() => {
		uni.hideLoading()
		uni.showToast({
			title: '支付成功',
			icon: 'success'
		})
		
		// 跳转到订单列表
		setTimeout(() => {
			uni.redirectTo({
				url: '/pages/order/list'
			})
		}, 1500)
	}, 2000)
}
</script>

<style>
.container {
	min-height: 100vh;
	background-color: #F5F5F5;
	padding-bottom: 120rpx;
}

/* 支付金额样式 */
.amount-section {
	background-color: #FFFFFF;
	padding: 40rpx 30rpx;
	margin-bottom: 20rpx;
	text-align: center;
}

.label {
	font-size: 28rpx;
	color: #666;
}

.amount {
	font-size: 60rpx;
	color: #D02B29;
	font-weight: bold;
	margin-top: 20rpx;
	display: block;
}

/* 支付方式样式 */
.payment-section {
	background-color: #FFFFFF;
	padding: 30rpx;
}

.section-title {
	font-size: 32rpx;
	font-weight: bold;
	color: #333;
	margin-bottom: 30rpx;
	display: block;
}

.payment-list {
	display: flex;
	flex-direction: column;
}

.payment-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 30rpx 0;
	border-bottom: 1rpx solid #EEEEEE;
}

.payment-item:last-child {
	border-bottom: none;
}

.method-info {
	display: flex;
	align-items: center;
}

.method-icon {
	font-size: 40rpx;
	margin-right: 20rpx;
}

.method-name {
	font-size: 28rpx;
	color: #333;
}

.check-icon {
	font-size: 32rpx;
	color: #D02B29;
}

.payment-item.active {
	background-color: #FFF0F0;
}

/* 底部支付按钮样式 */
.footer {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	height: 100rpx;
	background-color: #FFFFFF;
	display: flex;
	align-items: center;
	padding: 0 30rpx;
}

.pay-btn {
	width: 100%;
	height: 80rpx;
	line-height: 80rpx;
	text-align: center;
	background-color: #D02B29;
	color: #FFFFFF;
	border-radius: 40rpx;
	font-size: 32rpx;
}
</style> 